package main.java.FSMDE.validation.rules;

import java.util.ArrayList;
import java.util.List;

import main.java.FSMDE.models.Diagram;
import main.java.FSMDE.models.Transition;
import main.java.FSMDE.models.TransitionControl;
import main.java.FSMDE.models.TransitionType;
import main.java.FSMDE.validation.IValidationEntry;


public class TransitionControlShouldBeTriggerredValidator implements
		IRulesValidator {

	@Override
	public Iterable<IValidationEntry> validate(Diagram diagram) {
		List<IValidationEntry> entries = new ArrayList<IValidationEntry>();

		// transition must have destination interface
		for(Transition transition : diagram.getTransitions()){
			if(transition.getType().equals(TransitionType.Control)){
				if( ((TransitionControl)transition).getTriggerComponent() == null ) entries.add(new TransitionControlShouldBeTriggerredValidationEntry(diagram, transition));
			}
		}
		
		return entries;
	}

}
